from PIL import Image
import ImageFilter
from operator import itemgetter
im = Image.open('6008.jpg')
im2 = im.convert("P")
#im2.show()
his= im2.histogram()
values = {}

for i in range(256):
  values[i] = his[i]

for j,k in sorted(values.items(), key=itemgetter(1), reverse=True)[:10]:
  print j,k
#im3 = im2.filter(ImageFilter.MedianFilter())
#im3.show()
